Lauren
April 9th, 2020
Lauren Yee is multifaceted researcher and data scientist. She currently works in the consulting industry and designs projects around data visualization, dashboards and ecological and spatial analysis.
Ann Greenwood is the Education and Training Lead for Population Data BC. She manages a variety of education and training services for researchers and population health professionals . Services include an online certificate course in Population Health Data Analysis, live webinar-based courses, free online self -paced workshops, colloquium presentations/webinars and in-person workshops.
Any HTML format in RMarkdown can add interactivity. HTML is a markup language that gives context and structure to web based content. CSS is the rules and styling of that content.
Most interaction comes from JavaScript libraries that have been translated to R
What is JavaScript?“JavaScript is a programming language that allows you to implement complex things on web pages. Every time a web page does more than just sit there and display static information for you to look at—displaying timely content updates, interactive maps, animated 2D/3D graphics, scrolling video jukeboxes, or more—you can bet that JavaScript is probably involved.”
(Source: https://developer.mozilla.org/en-US/docs/Learn/JavaScript)
htmlwidgets contains a list of HTML widgets based on JavaScript for R
Data Tables DT format html tables, sort, filter
Plot.ly interactive plots, wrapper for ggplot2
Leaflet interactive maps
…many others
Not in this workshop:
crosstalk or interaction between widgets
RShiny builds interactive web applications
Add interactive, scrollable, searchable, filterable tables
plotly is an R package to create interactive graphics. The main function we will be using is ggplotly in plotly
ggplotly transforms ggplot2 objects into interactive plotly objects powered by JavaScript graphing library plotly.js.
Tabsets
Table of Contents
gganimate extends ggplot2 to include animation.
transitions are functions that interpret the plot data to distribute it over a number of frames
transition_states() splits up the plot data by a discrete variable and animates between different states
ease_aes() define the velocity for how the aesthetics change during an animation
enter and exit modify how data appearing and exiting the plot are animated
p <- ggplot(iris, aes(x = Petal.Width, y = Petal.Length)) +
geom_point(aes(colour = Species))
anim <- p +
transition_states(Species,
transition_length = 2,
state_length = 1)
animate(anim)Leaflet is a popular javascript library for interactive maps. It has many features:
sf or sp